/*
 * Nivel.cpp
 *
 * Author: Grupo Nro.
 */

#include "Nivel.h"

using std::vector;
using std::pair;
using std::string;

Nivel::Nivel() {
    id = -1;
    map_height = 0;
    map_width = 0;
    number_of_enemies = 0;
}

Nivel::Nivel(int id) {
	this->id = id;
	map_height = 0;
	map_width = 0;
	number_of_enemies = 0;
}

Nivel::~Nivel() {
	// Map Objects
	std::size_t i;
	for (i = 0; i < map_objects.size(); i++){
		delete map_objects[i];
	}
	// Spawners
	for (i = 0; i < spawners.size(); i++){
		delete spawners[i];
	}
	// Plants
	for (i = 0; i < plants.size(); i++){
	    delete plants[i];
	}
	// Bomberman spawn points
	bomberman_spawns.clear();
}


int Nivel::getId(){
	return id;
}

void Nivel::addMapObject(MapObject* mapObject){
	map_objects.push_back(mapObject);
}

vector<MapObject*>& Nivel::getMapObjects(){
	return map_objects;
}

void Nivel::addSpawner(Spawner& spawner) {
    spawners.push_back(&spawner);
}

vector<Spawner*>& Nivel::getSpawners() {
    return spawners;
}

void Nivel::addPlant(Plant& plant) {
    plants.push_back(&plant);
}

vector<Plant*>& Nivel::getPlants() {
    return plants;
}

void Nivel::setMapHeight(int height) {
    map_height = height;
}

int Nivel::getMapHeight() {
    return map_height;
}

void Nivel::setMapWidth(int width) {
    map_width = width;
}

int Nivel::getMapWidth() {
    return map_width;
}

void Nivel::addBombermanSpawnPoint(int x, int y) {
    bomberman_spawns.push_back(pair<int, int>(x, y));
}

vector<pair<int, int> >& Nivel::getBombermanSpawnPoints() {
    return bomberman_spawns;
}

void Nivel::setNumberOfEnemies(int enemies) {
    number_of_enemies = enemies;
}

int Nivel::getNumberOfEnemies() {
    return number_of_enemies;
}

void Nivel::setTileMapRepresentation(string tile_map_representation) {
    this->tile_map_representation = tile_map_representation;
}

string& Nivel::getTileMapRepresentation() {
    return tile_map_representation;
}
